package com.lefevre.cms.bean.mediaProcess;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 媒体处理队列
 *
 * @author Lefevre
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("media_process_queue")
@Entity
@Table(name = "media_process_queue", indexes = {@Index(name = "media_process_queue_1_idx", columnList = "processProgress"), @Index(name = "mediaProcessQueue_2_idx", columnList = "fileName")})
public class MediaProcessQueue implements Serializable {
    private static final long serialVersionUID = 7242129516093781064L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(type = IdType.INPUT)
    private Long id;

    /**
     * 模块 10:话题
     **/
    @TableField("module")
    private Integer module;

    /**
     * 参数 话题Id
     **/
    @Column(length = 100)
    @TableField("parameter")
    private String parameter;

    /**
     * 标题
     **/
    @Transient
    @TableField(exist = false)
    private String title;

    /**
     * 提交时间
     **/
    @Temporal(TemporalType.TIMESTAMP)
    @TableField("postTime")
    private Date postTime = new Date();

    /**
     * 类型 10:视频 20:音频
     **/
    @TableField("type")
    private Integer type;

    /**
     * 待处理文件路径
     **/
    @TableField("filePath")
    private String filePath;

    /**
     * 待处理文件名称
     **/
    @Column(length = 100)
    @TableField("fileName")
    private String fileName;

    /**
     * 处理文件的客户端IP
     **/
    @Column(length = 45)
    @TableField("ip")
    private String ip;

    /**
     * 处理进度 -1为还没有客户端领取本任务 0为已有客户端领取本任务 0以上为处理进度
     **/
    @TableField("processProgress")
    private Double processProgress = -1d;

    /**
     * 错误信息  组合成json List<String>类型
     **/
    @Lob
    @TableField("errorInfo")
    private String errorInfo = "[";

    @Transient
    @TableField(exist = false)
    private List<String> errorInfoList = new ArrayList<>();

}
